Deckgl Charts ¶
Choropleth Chart ¶
-
deckgl.choropleth( x , color_column , elevation_column=None , color_aggregate_fn='count' , color_factor=1 , elevation_aggregate_fn='sum' , elevation_factor=1 , data_points=100 , add_interaction=True , width=800 , height=400 , step_size=None , step_size_type=<class 'int'> , geoJSONSource=None , geoJSONProperty=None , geo_color_palette=None , mapbox_api_key=None , map_style='dark' , tooltip=True , \*\*library_specific_params ) ¶ -
- Parameters
-
- x: str
-
x-axis column name from the gpu dataframe
- color_column: str
-
column name from the gpu dataframe on which color palettes are based on
- elevation_column: str | Optional
-
column name from the gpu dataframe on which elevation scale is based on
- color_aggregate_fn: {‘count’, ‘mean’, ‘sum’, ‘min’, ‘max’, ‘std’},
- default “count”
-
aggregate function to be applied on the color column while performing groupby aggregation by column x
- color_factor: float, default 1
-
factor to be multiplied to each value of color column before mapping the color
- elevation_aggregate_fn: {‘count’, ‘mean’, ‘sum’, ‘min’, ‘max’, ‘std’},
- default “count”
-
aggregate function to be applied on the elevation column while performing groupby aggregation by column x
- elevation_factor: float, default 1
-
factor to be multiplied to each value of elevation column before scaling the elevation
- data_points: int, default 100
- add_interaction: {True, False}, default True
- width: int, default 800
- height: int, default 400
- step_size: int, default 1
- step_size_type: {int, float}, default int
- geoJSONSource: str
-
url to the geoJSON file
- geoJSONProperty: str, optional
-
Property to use while doing aggregation operations using the geoJSON file. Defaults to the first value in properties in geoJSON file.
- geo_color_palette: bokeh.palette, default bokeh.palettes.Inferno256
- nan_color: str, default white
-
color of the patches of value NaN in the map.
- mapbox_api_key: str, default os.getenv(‘MAPBOX_API_KEY’)
- map_style: {‘dark’, ‘light’}, default ‘dark’
-
map background type
- tooltip: {True, False}, default True
- title: str,
-
chart title
- **library_specific_params:
-
additional library specific keyword arguments to be passed to the function
- Returns
-
- A bokeh chart object of type 3dchoropleth
Example 3d-Choropleth ¶
import numpy as np
import cudf
import cuxfilter
geoJSONSource='https://raw.githubusercontent.com/rapidsai/cuxfilter/GTC-2018-mortgage-visualization/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json'
size = 1000
cux_df = cuxfilter.DataFrame.from_dataframe(
cudf.DataFrame({
'color':np.random.randint(20,30, size=size*10)/100,
'zip': list(np.arange(1,1001))*10,
'elevation': np.random.randint(0,1000, size=size*10)
})
)
chart0 = cuxfilter.charts.choropleth( x='zip', color_column='color', color_aggregate_fn='mean',
elevation_column='elevation', elevation_factor=1000, elevation_aggregate_fn='mean',
geoJSONSource=geoJSONSource, data_points=size, add_interaction=True
)
#declare dashboard
d = cux_df.dashboard([chart0],theme = cuxfilter.themes.dark, title='Mortgage Dashboard')
# cuxfilter.load_notebook_assets()
chart0.view()
Example 2d-Choropleth ¶
import numpy as np
import cudf
import cuxfilter
geoJSONSource='https://raw.githubusercontent.com/rapidsai/cuxfilter/GTC-2018-mortgage-visualization/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json'
size = 1000
cux_df = cuxfilter.DataFrame.from_dataframe(
cudf.DataFrame({
'color':np.random.randint(20,30, size=size*10)/100,
'zip': list(np.arange(1,1001))*10,
'elevation': np.random.randint(0,1000, size=size*10)
})
)
chart0 = cuxfilter.charts.choropleth( x='zip', color_column='color', color_aggregate_fn='mean',
geoJSONSource=geoJSONSource, data_points=size, add_interaction=True
)
#declare dashboard
d = cux_df.dashboard([chart0],theme = cuxfilter.themes.dark, title='Mortgage Dashboard')
# cuxfilter.load_notebook_assets()
chart0.view()